package br.com.paiva.container;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
@Table(name="formularioBooking")
public class FormularioBooking {
	
	@Id
	@GeneratedValue
	@Column(name="id_formularioBooking")
	private long id;
	
	@Column(name="numero")
	private String numero;
	
	@Column(name="valor")
	private String valor;
	
	@Column(name="proformaInvoice")
	private String proformaInvoice;
	
	@Column(name="pOrder")
	private String pOrder;
	
	@Column(name="origem")
	private String origem;
	
	@Column(name="destino")
	private String destino;
	
	@Column(name="grossWeight")
	private String grossWeight;
	
	@Column(name="netWeight")
	private String netWeight;
	
	@Column(name="rate")
	private String rate;
	
	@Column(name="currency")
	private String currency;
	
	@Column(name="frete")
	private String frete;
	
	@OneToMany(mappedBy="formularioBooking")
	private List<Taxa> taxas;
	
	@OneToMany(mappedBy="formularioBooking")
	private List<Companhia> companhias;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="id_awb",	insertable=true, updatable=true)
	@Fetch(FetchMode.JOIN)
	@Cascade(CascadeType.SAVE_UPDATE)
	private AWB awb;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="id_mawb",	insertable=true, updatable=true)
	@Fetch(FetchMode.JOIN)
	@Cascade(CascadeType.SAVE_UPDATE)
	private MAWB mawb;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="id_hawb",	insertable=true, updatable=true)
	@Fetch(FetchMode.JOIN)
	@Cascade(CascadeType.SAVE_UPDATE)
	private HAWB hawb;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="id_aeroporto", insertable=true, updatable=true)
	@Fetch(FetchMode.JOIN)
	@Cascade(CascadeType.SAVE_UPDATE)
	private Aeroporto aeroporto;
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getNumero() {
		return numero;
	}

	public void setNumero(String numero) {
		this.numero = numero;
	}

	public String getValor() {
		return valor;
	}

	public void setValor(String valor) {
		this.valor = valor;
	}

	public String getProformaInvoice() {
		return proformaInvoice;
	}

	public void setProformaInvoice(String proformaInvoice) {
		this.proformaInvoice = proformaInvoice;
	}

	public String getpOrder() {
		return pOrder;
	}

	public void setpOrder(String pOrder) {
		this.pOrder = pOrder;
	}

	public String getOrigem() {
		return origem;
	}

	public void setOrigem(String origem) {
		this.origem = origem;
	}

	public String getDestino() {
		return destino;
	}

	public void setDestino(String destino) {
		this.destino = destino;
	}

	public String getGrossWeight() {
		return grossWeight;
	}

	public void setGrossWeight(String grossWeight) {
		this.grossWeight = grossWeight;
	}

	public String getNetWeight() {
		return netWeight;
	}

	public void setNetWeight(String netWeight) {
		this.netWeight = netWeight;
	}

	public String getRate() {
		return rate;
	}

	public void setRate(String rate) {
		this.rate = rate;
	}

	public String getCurrency() {
		return currency;
	}

	public void setCurrency(String currency) {
		this.currency = currency;
	}

	public String getFrete() {
		return frete;
	}

	public void setFrete(String frete) {
		this.frete = frete;
	}

	public List<Taxa> getTaxas() {
		return taxas;
	}

	public void setTaxas(List<Taxa> taxas) {
		this.taxas = taxas;
	}

	public List<Companhia> getCompanhias() {
		return companhias;
	}

	public void setCompanhias(List<Companhia> companhias) {
		this.companhias = companhias;
	}

	public AWB getAwb() {
		return awb;
	}

	public void setAwb(AWB awb) {
		this.awb = awb;
	}

	public MAWB getMawb() {
		return mawb;
	}

	public void setMawb(MAWB mawb) {
		this.mawb = mawb;
	}

	public HAWB getHawb() {
		return hawb;
	}

	public void setHawb(HAWB hawb) {
		this.hawb = hawb;
	}

	public Aeroporto getAeroporto() {
		return aeroporto;
	}

	public void setAeroporto(Aeroporto aeroporto) {
		this.aeroporto = aeroporto;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (id ^ (id >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		FormularioBooking other = (FormularioBooking) obj;
		if (id != other.id)
			return false;
		return true;
	}
}
